home *** CD-ROM | disk | FTP | other *** search
- ******************************************************************
- * COPYRIGHT (C) 1986 by Donald Krantz and James Stanley
- * - Note: This is a real, live, actual, registered copyright,
- * and should be treated as such. This source code is from
- * the book "68000 Assembly Language", Krantz and Stanley,
- * Addison-Wesley Publishing Company, Reading, MA, 1986.
- *
- * Permission granted by the authors for non-commercial use
- * in programs released to the public domain, as long as this
- * copyright notice remains attached and visible.
- *
- *****************************************************************
- * GROUP 3 (WIndowing) Commands
-
- xref get_buf,prompt,prtscr,sync_cur,case,cursor
- xref _getkey,cls,cmd_w,border_w,used,set_w,open_w
- xdef g_3,refresh
-
- #edit.h
- #cursor.h
-
- *****************************************************************
- * G_3 - Group 3 (window) commands processor
- g_3:
- move.l #w_cmd,a0 * load prompt string address
- bsr prompt * output prompt
- bsr _getkey * get switch key
- and.w #$001F,d0 * make u/l case into ctrl char
- move.l #table3,a0 * setup case switch table
- bsr case * process choices
- rts * resume editing
- w_cmd: dc.b 'Window Commands: P R E X',0
- dc.w 0
- *****************************************************************
- * TABLE3 - switch table for group 3 (window) commands
- table3:
- dc.w 4 * four choices
- dc.w $10 * ^P - pop new window
- dc.l pop
- dc.w $12 * ^R - rotate windows
- dc.l rotate
- dc.w c_up * move UL corner of window
- dc.l upleft
- dc.w c_down * move LR corner of window
- dc.l lowright
- dc.l default * "others" choice
- default:
- rts
- *****************************************************************
- * UPLEFT - Moves the upper left corner of the active window
- upleft:
- lea w_ulbx(a5),a2 * pointer to X left side
- lea w_ulby(a5),a1 * pointer to Y top
- move.w #lim_lx,d1 * X left limit
- move.w w_lrbx(a5),d2 * X right limit
- sub.w #12,d2 * must be at least 10 chars wide
- move.w #lim_uy,d5 * Y top limit
- move.w w_lrby(a5),d4 * Y bottom limit
- sub.w #2,d4 * must be at least 3 high
- bsr mover * use common code
- bsr refresh * have to remake screen
- rts
- *****************************************************************
- * LOWRIGHT - moves the lower right corner of the window
- lowright:
- lea w_lrbx(a5),a2 * pointer to X right side
- lea w_lrby(a5),a1 * pointer to Y bottom
- move.w #lim_rx,d2 * X right limit
- move.w w_ulbx(a5),d1 * X left limit
- add.w #12,d1 * must be at least 10 chars wide
- move.w #lim_ly,d4 * Y bottom limit
- move.w w_ulby(a5),d5 * Y top limit
- add.w #2,d5 * must be at least 3 high
- bsr mover * use common code
- bsr refresh * have to remake screen
- rts
- *****************************************************************
- * MOVER - moves the window corners around
- mover:
- move.w (a1),-(a7) * push cursor Y
- move.w (a2),-(a7) * push cursor X
- bsr cursor * move cursor to window corner
- addq.l #4,a7 * adjust stack
- bsr sync_curs * make sure cursor moves
- bsr _getkey * go see what human has in mind
- move.l #mtable,a0 * get case switch table ready
- bra case * do what human wants... maybe.
- *****************************************************************
- * MTABLE - window streching case dispatch table
- mtable:
- dc.w 9 * 9 choices for this case
- dc.w c_up * cursor up
- dc.l oneup
- dc.w c_down * cursor down
- dc.l onedn
- dc.w c_right * cursor right
- dc.l onert
- dc.w c_left * cursor left
- dc.l onelf
- dc.w page_up * max up
- dc.l allup
- dc.w page_down * max down
- dc.l alldn
- dc.w c_w_right * max right
- dc.l allrt
- dc.w c_w_left * max left
- dc.l alllf
- dc.w return * mods complete
- dc.l done
- dc.l mover * default case (no action)
- *****************************************************************
- oneup:
- cmp.w (a1),d5 * check top limit
- beq mover * branch on limit
- sub.w #1,(a1) * move up one line
- bra mover
- *****************************************************************
- onedn:
- cmp.w (a1),d4 * check bottom limit
- beq mover * branch on limit
- addq.w #1,(a1) * move down one line
- bra mover
- *****************************************************************
- onert:
- cmp.w (a2),d2 * check right limit
- beq mover * branch on limit
- addq.w #1,(a2) * move one char right
- bra mover
- *****************************************************************
- onelf:
- cmp.w (a2),d1 * check left limit
- beq mover * branch on limit
- subq.w #1,(a2) * move left one char
- bra mover
- *****************************************************************
- allup:
- move.w d5,(a1) * set to upper limit
- bra mover
- *****************************************************************
- alldn:
- move.w d4,(a1) * set to lower limit
- bra mover
- *****************************************************************
- alllf:
- move.w d1,(a2) * set to left limit
- bra mover
- *****************************************************************
- allrt:
- move.w d2,(a2) * set to right limit
- bra mover
- *****************************************************************
- done:
- move.w w_ulbx(a5),d0 * reset window params
- move.w w_ulby(a5),d1
- move.w w_lrbx(a5),d2
- move.w w_lrby(a5),d3
- bsr set_w * setup new parameters
- rts
- *****************************************************************
- * POP - opens a new window for editing
- pop:
- bsr get_buf * get new buffer
- rts
- *****************************************************************
- * ROTATE - pulls the bottom active screen to the top.
- rotate:
- move.l a5,a0 * get active screen
- move.l a5,a1 * prime "last good" pointer
- lp0_rt:
- tst.l (a0) * is there another window?
- beq sk0_rt * no, jump out
- move.l a0,a1 * save this pointer
- move.l (a0),a0 * get next window
- bra lp0_rt * keep looping
- sk0_rt:
- move.l a5,(a0) * link to former top window
- move.l a0,used * move former bottom to root
- move.l a0,a5 * make former bottom active
- clr.l (a1) * mark last window
- bsr border_w * re-establish correct frame
- rts
- *****************************************************************
- * REFRESH - redraws all screen buffers, leaves a5 set to top win.
- refresh:
- bsr cls * get rid of stuff on the screen
- clr.w d1 * count the windows to open
- move.l #cmd_w,a5 * we have to reopen cmd window
- bsr open_w * so we do.
- move.l used,a5 * get first active window address
- lp0_rf:
- move.l a5,-(a7) * push a window address
- beq sk0_rf * jump out if null
- addq.w #1,d1 * increment window count
- move.l (a5),a5 * get next window address
- bra lp0_rf * and keep on doon it.
- sk0_rf:
- addq.l #4,a7 * pop null on top of stack
- bra sk1_rf * do loop test before loop
- lp2_rf:
- move.l (a7)+,a5 * pop the window
- bsr open_w * open the window
- bsr prtscr * print the contents
- sk1_rf:
- dbra d1,lp2_rf
- rts